import java.util.*;

public class Main {
    public static void main(String[] args) throws InterruptedException {
        Scanner sc = new Scanner(System.in);
        List<Staff> ss=new ArrayList<Staff>();
        ss.add(new Staff(1,500,400,"职工1","female"));
        ss.add(new Staff(2,400,600,"职工2","female"));
        ss.add(new Staff(3,600,300,"职工3","male"));
        ss.add(new Staff(4,800,200,"职工4","female"));
        ss.add(new Staff(5,500,700,"职工5","male"));

        Collections.sort(ss);
        System.out.println("编号,团险,个险,姓名,性别");
        for (Staff s:ss){
            System.out.println(s.toString());
        }
        ss.sort(new newComparetor());
        System.out.println("编号,团险,个险,姓名,性别");
        for (Staff s:ss){
            System.out.println(s.toString());
        }


    }
}

class Staff implements Comparable<Staff>{
    private int number;
    private int tscore;
    private int pscore;
    private String name ;
    private String sex;

    public Staff() {
    }

    public Staff(int number, int tscore, int pscore, String name, String sex) {
        this.number = number;
        this.tscore = tscore;
        this.pscore = pscore;
        this.name = name;
        this.sex = sex;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getTscore() {
        return tscore;
    }

    public void setTscore(int tscore) {
        this.tscore = tscore;
    }

    public int getPscore() {
        return pscore;
    }

    public void setPscore(int pscore) {
        this.pscore = pscore;
    }

    @Override
    public int compareTo(Staff s) {
        int ret=this.pscore+this.tscore-s.getPscore()-s.getTscore();
        if (ret>0)ret=1;
        else if (ret<0)ret=-1;
        return ret;
    }

    @Override
    public String toString() {
        return number +
                "," + tscore +
                "," + pscore +
                "," + name +
                "," + sex;
    }
}

class newComparetor implements Comparator<Staff> {
    public newComparetor() {
    }

    @Override
    public int compare(Staff o1, Staff o2) {
        int ret=o1.getTscore()-o2.getTscore();
        if (ret>0)ret=1;
        else if (ret<0)ret=-1;
        return ret;
    }
}
